//全局配置ajax

//1.在headers中添加token
var token = sessionStorage.token;

$.ajaxSetup({
	headers: { Authorization: `Bearer ${token}` },
	error: function(XMLHttpRequest, textStatus, errorThrown) {
		var status = XMLHttpRequest.status;
		switch (status) {
			case 401:
				layer.msg('401：token失效，请重新登录！');
				location.replace('./login.html');
				break;
			case 404:
				layer.msg('404：接口地址不存在！');
				break;
			case 500:
				layer.msg('500：服务器内部错误！');
				break;

			default:
				break;
		}
	}
});

//2.处理ajax错误异常
